﻿// Decompiled with JetBrains decompiler
// Type: StoryMode.Quests.TutorialPhase.RecruitTroopsTutorialQuest
// Assembly: StoryMode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 11BAE65F-6C15-4628-A9C6-1B968588CDA1
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\Modules\StoryMode\bin\Win64_Shipping_Client\StoryMode.dll

using StoryMode.Quests.QuestTasks;
using System;
using System.Collections.Generic;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;
using TaleWorlds.SaveSystem;

#nullable disable
namespace StoryMode.Quests.TutorialPhase
{
  public class RecruitTroopsTutorialQuest : StoryModeQuestBase
  {
    public const int RecruitTroopAmount = 4;
    [SaveableField(1)]
    private readonly RecruitTroopTutorialQuestTask _recruitTroopTutorialQuestTask;

    private TextObject _recruitTroopTaskStartLog
    {
      get
      {
        return new TextObject("{=vCBuF6dq}Recruit 4 recruits. Click \"Recruit Troops\" option on village menu to recruit troops.");
      }
    }

    public override TextObject Title => new TextObject("{=y3fn2vWY}Recruit Troops");

    public RecruitTroopsTutorialQuest(Hero questGiver)
      : base("recruit_troops_tutorial_quest", questGiver, CampaignTime.Never)
    {
      this.SetDialogs();
      this._recruitTroopTutorialQuestTask = new RecruitTroopTutorialQuestTask(new Action(this.RecruitTaskOnSuccess), 4, new Func<CharacterObject, bool>(this.DoesRecruitedTroopSatifyRecruitTroopTask), Settlement.CurrentSettlement, this.AddDiscreteLog(this._recruitTroopTaskStartLog, new TextObject("{=y3fn2vWY}Recruit Troops"), 0, 4));
      this.AddTask((QuestTaskBase) this._recruitTroopTutorialQuestTask);
    }

    protected override void SetDialogs()
    {
    }

    protected override void InitializeQuestOnGameLoad()
    {
      this.SetDialogs();
      this._recruitTroopTutorialQuestTask.AddTaskBehaviorsOnGameLoad(new Action(this.RecruitTaskOnSuccess));
      this._recruitTroopTutorialQuestTask.InitializeTaskOnLoad(4, new Func<CharacterObject, bool>(this.DoesRecruitedTroopSatifyRecruitTroopTask), Settlement.Find("village_ES3_2"));
    }

    protected override void HourlyTick()
    {
    }

    private bool DoesRecruitedTroopSatifyRecruitTroopTask(CharacterObject troop) => true;

    private void RecruitTaskOnSuccess() => this.CompleteQuestWithSuccess();

    internal static void AutoGeneratedStaticCollectObjectsRecruitTroopsTutorialQuest(
      object o,
      List<object> collectedObjects)
    {
      ((MBObjectBase) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this._recruitTroopTutorialQuestTask);
    }

    internal static object AutoGeneratedGetMemberValue_recruitTroopTutorialQuestTask(object o)
    {
      return (object) ((RecruitTroopsTutorialQuest) o)._recruitTroopTutorialQuestTask;
    }
  }
}
